function get_pos(e){
	var e =e|| window.Event;
	return {x:e.pageX||(e.clientX?e.clientX+document.documentElement.scrollLeft:0),y:e.pageY||(e.clientY?e.clientY+document.documentElement.scrollTop:0)};
}
function box(title,width,height,content){
	var mask_left=-(width+14)/2;
	var mask_top=-(height+14)/2;
	var body_left=-width/2;
	var body_top=-height/2;
	var box_mask=$("<div />").attr('id','box_mask').addClass('box_mask').css({'width':'100%','height':$(document).height()+'px'}).appendTo('body');
	var box_body=$("<div />").attr('id','box_body').addClass('box_body').css({'width':width,'height':height,'marginLeft':body_left+'px','marginTop':body_top+'px'}).appendTo('body');
	var box_caption=$("<div />").attr('id','box_caption').addClass('box_caption').appendTo(box_body).append(title);
	var box_button=$("<div />").attr('id','box_button').addClass('box_button').appendTo(box_caption);
	var box_content=$("<div />").attr('id','box_content').addClass('box_content').appendTo(box_body).html(content);
		box_button.click(function(){			
			box_body.empty();
			box_body.remove();
			box_mask.remove();
		});
}
function add_favorite(){
	var title=document.title,url=document.location.href;
	if (window.sidebar){ 
		window.sidebar.addPanel(title, url,""); 
	}else if( document.all){ 
		window.external.AddFavorite(url,title); 
	}
}
  
function setHomepage(){
	if (document.all){
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(document.URL);
	}else if (window.sidebar){
		if(window.netscape){
			try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");    
			}catch (e){
				alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );    
			}
		}
	var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);   
	prefs.setCharPref('browser.startup.homepage',document.URL); 
	}
}

function setTab(name,cursel){
	cursel_0=cursel;
	for(var i=1; i<=links_len; i++){
		var menu = document.getElementById(name+i);
		var menudiv = document.getElementById("con_"+name+"_"+i);
		if(i==cursel){
			menu.className="off";
			menudiv.style.display="";
		}
		else{
			menu.className="";
			menudiv.style.display="none";
		}
	}
}
function Next(){                                                        
	cursel_0++;
	if (cursel_0>links_len)cursel_0=1
	setTab(name_0,cursel_0);
} 
var name_0='one';
var cursel_0=1;
var ScrollTime=4000;
var links_len,iIntervalId;
onload=function(){
	var links = document.getElementById("tab1").getElementsByTagName('li')
	links_len=links.length;
	for(var i=0; i<links_len; i++){
		links[i].onmouseover=function(){
			clearInterval(iIntervalId);
			this.onmouseout=function(){
				iIntervalId = setInterval(Next,ScrollTime);;
			}
		}
	}
	document.getElementById("con_"+name_0+"_"+links_len).parentNode.onmouseover=function(){
		clearInterval(iIntervalId);
		this.onmouseout=function(){
			iIntervalId = setInterval(Next,ScrollTime);;
		}
	}
	setTab(name_0,cursel_0);
	iIntervalId = setInterval(Next,ScrollTime);
}

$(function(){
    $('#nav li:has(ul)').hover(function(){
            $(this).find('ul').delay(250).slideDown(400);
    },function(){
            $(this).find('ul').stop(true,true).fadeOut(200);
    });

	$(window).scroll(function(){
		var windowScrollTop = $(window).scrollTop();
		var windowHeight = $(window).height();
		$("#rightDiv").css("top", windowScrollTop+200);
	}); 
});